package com.qf.controller;

import com.qf.entity.OrderRefundDetail;
import com.qf.entity.OrderRefundDetailVO;
import com.qf.service.OrderRefundDetailService;
import com.qf.util.AliyunOSSUtil;
import com.qf.util.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 天--道--酬--勤
 *
 * @author LiangGaoQiang
 * @ClassName OrderRefundDetailController
 * @Date: 2025/5/3 11:46
 * @Description: 描述
 */
@RestController
@RequestMapping("/refundDetail")
@ApiOperation(value = "退款明细管理")
public class OrderRefundDetailController {
    @Autowired
    private OrderRefundDetailService orderRefundDetailService;


    /**
     * 获取退款明细信息
     * @param refundId 退款申请id
     * @return R
     */
    @GetMapping("/getRefundInfo")
    @ApiOperation(value = "获取退款明细信息")
    public R getRefundInfo(Long refundId){
        List<OrderRefundDetailVO> list = orderRefundDetailService.getRefundInfo(refundId);
        if (list.size()>0){
            return R.ok(list);
        }
        return R.fail();
    }


    @PostMapping("/uploadPicture")
    @ApiOperation(value = "上传图片")
    public R upload(@RequestParam("file") MultipartFile file, @RequestParam("refundId") Long refundId) {
        String filePath = AliyunOSSUtil.upLoad(file);
        boolean result = orderRefundDetailService.updateRefundDetail(filePath, refundId);
        if (result) {
            return R.ok(filePath);
        }
        return R.fail();
    }

}
